<?php
namespace app\admin\controller;

use app\common\controller\AdminBase;
use think\Cache;
use think\Db;

/**
 * 系统配置
 * Class System
 * @package app\admin\controller
 */
class UploadIndex extends AdminBase
{
    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 上传官网图片
     */
    public function index()
    {
        $info = Db::name('system')->field('value')->where('name', 'site_index')->find();
        $info = unserialize($info['value']);
        // dump($info);exit();
        return $this->fetch('system/uploadindex', ['site_index' => $info['site_index'],'small_img'=>$info['small_img'],'dynamics'=>$info['dynamics']]);
    }

    /**
     * 更新官网图片
     */
    public function updateIndex(){
        if ($this->request->isPost()) {
            $site_index                = $this->request->post();
            // $site_index['site_tongji'] = htmlspecialchars_decode($site_index['site_tongji']);
            $data['value']              = serialize($site_index);
            if (Db::name('system')->where('name', 'site_index')->update($data) !== false) {
                $this->success('提交成功');
            } else {
                $this->error('提交失败');
            }
        }
    }
}